import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        editableTabsValue: "index",
        editableTabs: [{
            title: "首页",
            name: "index",
        }],
        token: '',
    },
    mutations: {
        addTab(state, tab) {
            let res = state.editableTabs.findIndex(e => e.name === tab.name)
            if (res === -1) {
                state.editableTabs.push(tab);
            }
            state.editableTabsValue = tab.name;
        },
        set_token(state, token) {
            state.token = token;
            localStorage.setItem("token", token);
        },
        remove_token(state, token) {
            state.token = token;
            localStorage.removeItem("token");
        },
    },
    actions: {},
    modules: {}
})